package cn.edu.njuit.lesson9heros.service.impl;

import cn.edu.njuit.lesson9heros.myioc.MyComponent;
import cn.edu.njuit.lesson9heros.pojo.Team;
import cn.edu.njuit.lesson9heros.service.HeroService;
import cn.edu.njuit.lesson9heros.service.ImplFactory;
import cn.edu.njuit.lesson9heros.service.TeamService;

@MyComponent(name="teamService")
public class TeamServiceImpl implements TeamService {
    @Override
    public Team getTeam() {
        HeroService heroService= ImplFactory.getHeroServiceImpl();
        Team team=new Team();
        team.setAdcHero(heroService.getHeroByPosition("adc"));
        //排除adc英雄
        team.setJungleHero(heroService.getHeroByPosition("jungle",team.getAdcHero().getHeroId()));
        //排除已选择的adc和刺客
        team.setMidHero(heroService.getHeroByPosition("mid",team.getAdcHero().getHeroId(),
                                                                        team.getJungleHero().getHeroId()));
        //排除已选择的adc、刺客、中路
        team.setSupportHero(heroService.getHeroByPosition("support",team.getAdcHero().getHeroId(),
                                                                                team.getJungleHero().getHeroId(),
                                                                                team.getMidHero().getHeroId()));
        //排除已选择的adc、刺客、中路、辅助
        team.setTopHero(heroService.getHeroByPosition("top",team.getAdcHero().getHeroId(),
                                                                        team.getJungleHero().getHeroId(),
                                                                        team.getMidHero().getHeroId(),
                                                                        team.getSupportHero().getHeroId()));
        return team;
    }
}
